#ifndef YafridngRenderManager_H
#define YafridngRenderManager_H

#include <Ice/Ice.h>
#include <IceUtil/Mutex.h>
#include <FileManager.h>
#include <ResultManager.h>
#include <Yafridng.h>
#include <Controller.h>

using namespace std;
using namespace Yafridng;

#define SLEEP -2
#define END -1
#define NOT_RENDERED 0
#define RENDERING 1
#define RENDERED 2

typedef struct{
  string renderer;
  int status;
  IceUtil::Time start;
  IceUtil::Time end;
}renderInfo;

class YafridngRenderManagerI : public YafridngRenderManager, public IceUtil::Mutex

{
 public:
  YafridngRenderManagerI(string file, 
			 string path,
			 int width,
			 int height,
			 TZones& zones,
			 ResultManagerPtr& resultManager,
			 Controller* c);

  virtual ::Ice::Int queryZone(const ::std::string& nodeId,
			       const ::Ice::Current&);

  virtual void updateZone_async(const AMD_YafridngRenderManager_updateZonePtr& cb,
				::Ice::Int zone, 
				const ::std::string& fileName,
				const ::Yafridng::FilePrx& fileSt,
				const ::Ice::Current&);

  void cancelRender(const ::std::string& nodeId);

 private:
  string _file;
  string _path;
  vector<renderInfo> _renderedZones;
  TZones _zones;
  int _width;
  int _height;
  int _rendered;
  ResultManagerPtr _resultManager;
  Controller* _control;
};

typedef IceUtil::Handle<YafridngRenderManagerI> YafridngRenderManagerIPtr;
#endif
